package org.clock.serviceImpl;

import java.util.*;

import org.clock.service.IDateService;

public class DateServiceImpl implements IDateService {
	public Date getCurrentDate() {
		Date now = new Date(System.currentTimeMillis());
		return now;
	}

	public int compareDate(Date date1, Date date2) {
		if((date1.getTime()-date2.getTime()<500) && (date1.getTime()-date2.getTime()>-500))
			return 0;
		if(date1.getTime()-date2.getTime()>500)
			return 1;
		if(date1.getTime()-date2.getTime()<-500)
			return -1;
		return 0;
	}

	public long differSeconds(Date date1, Date date2) {
		long diff = date1.getTime()-date2.getTime();
		if(diff>0)
			return diff;
		else
			return -diff;
	}

}
